# -*- coding: utf-8 -*-

from app.module.www import www
from app.model.common.member import Member as MemberModel
# from app import db
from flask import jsonify


@www.route('/')
def index():
    # 新增记录
    # one = MemberModel().add_member('4297f44b13955235245b2497399d7a93', 'san', '2@2.com', '13800002222', '0512', '2018-04-15 13:45:16', 0)
    # print(one)
    # 条件筛选
    ct, rss = MemberModel().get_member(
        3,
        {"member_id": "1", "real_name": "anti", "email": "1@1.com"},
        (MemberModel.member_id, MemberModel.real_name, MemberModel.email, MemberModel.pwd),
        1,
        20,
        MemberModel.member_id.asc()
    )
    print('----')
    print('Total: ' + str(ct))
    print('----')
    for rs in rss:
        print('********')
        print(rs.member_id)
        print(rs.real_name)
        print(rs.email)
        print(rs.pwd)
        print('********')
    return '<h1>WWW !</h1>'


@www.route('/hello')
def hello():
    # 返回json数据
    tasks = [
        {
            'id': 1,
            'title': u'Buy groceries',
            'description': u'Milk, Cheese, Pizza, Fruit, Tylenol',
            'done': False
        },
        {
            'id': 2,
            'title': u'Learn Python',
            'description': u'Need to find a good Python tutorial on the web',
            'done': False
        }
    ]
    return jsonify(tasks)
